package com.ws.gold.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**") // 所有路径都允许跨域
                .allowedOrigins("http://localhost:5173") // 只允许前端地址
                .allowedMethods("*") // 允许所有 HTTP 方法
                .allowedHeaders("*")
                .allowCredentials(true);
    }

}
